<%@ page contentType="text/html; charset=utf-8" language="java" %>
<%@ include file="/sys/include/header.jsp" %>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>工资系数管理</title>
<link href="sys/style01/css/table.css" rel="stylesheet" type="text/css">
<link href="sys/css/banzu.css" rel="stylesheet" type="text/css"  >
</head>

<script language="javascript">
	var trIndex = "${num}"; 
	function addParameteTd(obj){
		var oTd = obj.parentNode.parentNode.parentNode.parentNode.parentNode;//隐藏域最外层td
		var tdIndex = oTd.getElementsByTagName("input")[0].value;
		var otd1 = document.getElementById("tdCody1").cloneNode(true); 
		var otd2 = document.getElementById("tdCody2").cloneNode(true);
		 
		otd1.getElementsByTagName("input")[0].name="paramete_start"+tdIndex;
		otd1.getElementsByTagName("input")[0].id="paramete_start"+tdIndex;
		otd1.getElementsByTagName("input")[0].checkType="number"; 
		otd1.getElementsByTagName("input")[0].checkItem="工资系数区间";  
		otd1.getElementsByTagName("input")[1].name="paramete_end"+tdIndex;
		otd1.getElementsByTagName("input")[1].id="paramete_end"+tdIndex; 	
		otd1.getElementsByTagName("input")[1].checkType="number"; 
		otd1.getElementsByTagName("input")[1].checkItem="工资系数区间";	
		otd2.getElementsByTagName("input")[0].name="paramete_percent"+tdIndex;
		otd2.getElementsByTagName("input")[0].id="paramete_percent"+tdIndex; 
		//otd2.getElementsByTagName("input")[0].checkType="number" ; 
		//otd2.getElementsByTagName("input")[0].checkItem="工资项系数"; 
		
		var otd1Add = obj.parentNode.insertAdjacentElement("beforeBegin", otd1.cells(0));
		var tr2 = oTd.getElementsByTagName("tr")[1];
		var otd2Add = tr2.children(tr2.children.length-1).insertAdjacentElement("afterEnd", otd2.cells(0));
	}
	
	function addParameteTr(){
		trIndex++;
		
		var otr = document.getElementById("tbCody").getElementsByTagName("tr")[0].cloneNode(true);
		var tdIndex = otr.getElementsByTagName("INPUT");
		for(var i=0;i<tdIndex.length;i++){
			if(tdIndex[i].type=="checkbox") continue;
			if(tdIndex[i].name=="tdIndex") 
				tdIndex[i].value=trIndex;
			else {
				tdIndex[i].name=tdIndex[i].name+trIndex;
				tdIndex[i].id=tdIndex[i].id+trIndex;
			}
		}
		var btnTr = document.getElementById("btnTr");
		btnTr.insertAdjacentElement("beforeBegin", otr);	
	}
	
	function deleteChecked(){
		var chk = document.getElementsByName("chktd");
		var bool = true;
		for(var j =0;j<chk.length-1;j++){
			if(chk[j].checked){
				bool =false;
				deleteTr(chk[j]);
				j--;
			}	
		}	
		if(bool){
			alert("请选择需要删除的工资系数项！");
		}
	}
	
	function deleteTr(obj){	
		var oDelTr = obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
		oDelTr.parentNode.deleteRow(oDelTr.rowIndex);
	}
	
	function save(){	
		if(checkPageValid())
		document.queryFrom.submit();
	}
	
	function checkData(){	
		var salary_percent  = new Arrary();
		var oinput = document.queryFrom.getElementsByTagName("INPUT");
		for(var i=0;i<oinput.length;i++){
			if((oinput[i].name).indexOf("salary_percent")){
				if(!checknumber(oinput[i].value))
					salary_percent[salary_percent.length] = oinput[i].value;
			}
		}		
	}
	
	
</script>
<body class="ridgeBody" >
<fieldset align='left' style="width:100%">
 <legend><font  size="2">工资系数维护</legend>
  <form name="queryFrom" method="post" action="hr/createSalaryParameter.action"> 
<table width="100%" >
<c:forEach items="${spBean}" var="bean">
 <tr><td height="20" colspan="9"> 		
		<table  cellpadding='0' cellspacing='0' border='1' bordercolorDark='white' bordercolorLight='#BEBEBE' class="datatable">
			<tr>
				<td  height="20" align="center" style="width:40px;" rowspan="2" >
					<input id="tdIndex" name="tdIndex" value="${bean.inx}" type="hidden">
					<input name="chktd" id="chktd"  type="checkbox"  style="width:20px;" />
	  			</td>
				<td  height="20" align="center" style="width:100px;" rowspan="2" >
					<input name="salary_percent${bean.inx}" id="salary_percent${bean.inx}" type="text1" class="input"  checkItem="工资系数项所占比重" checkType="number" style="width:40px;" value="${bean.salary_percent}" />%
	  			</td>
	  			<td  height="20" align="center" class="dataTitle"  style="width:100px;" valign="baseline">工资系数项</td>
	  			<td  height="20" align="center" class="dataTitle"  style="width:100px;" valign="baseline">工资系数项单位</td>
	  			<c:forEach items="${bean.paramete}" var="map">
	  			<td  height="20" align="center" class="dataTitle"  valign="baseline">
					<input name="paramete_start${bean.inx}" id="paramete_start${bean.inx}" type="text" class="input" requiredValue="true" checkType="number" checkItem="工资系数区间" value="${map.paramete_start}" style="width:40px;" value="0"/>~<input name="paramete_end${bean.inx}" id="paramete_end${bean.inx}" checkType="number" checkItem="工资系数区间" size="2" type="text" value="${map.paramete_end}" class="input" style="width:40px;" value="0"/>
				</td>
				</c:forEach>
				<td  height="20" align="center" class="dataTitle" style="width:10px;"  valign="baseline">
				<img src="sys/images/add.gif" onclick = "addParameteTd(this);" title="新增一项" style="cursor:hand"/>
				</td>
  			</tr>	
  			<tr >
				<td  height="20" align="center" style="width:100px;"   rowspan="2" ><input name="salary_type${bean.inx}" id="salary_type${bean.inx}" type="text" checkLength="60" checkItem="工资系数项" class="input" value="${bean.salary_type}" style="width:100%;" /></td>
	  			<td  height="20" align="center" style="width:100px;"   valign="baseline"><input name="paramete_type${bean.inx}" id="paramete_type${bean.inx}" type="text" checkLength="60" checkItem="工资系数项单位" class="input" style="width:40px;" value="${bean.paramete_type}" /></td>
				<c:forEach items="${bean.paramete}" var="map2">
				<td  height="20" align="center" valign="baseline"><input name="paramete_percent${bean.inx}" id="paramete_percent${bean.inx}" type="text" class="input" style="width:40px;" value="${map2.paramete_percent}"   value="0" /></td>
				</c:forEach>
  			</tr>
		</table>
	</td></tr>
	</c:forEach>
	<!-- 
	<tr id="btnTr"><td height="20" colspan="9">
		<table width="100%" border="0" height="20" class="dataTitle">
			<tr >
				<td width="50%" height="20" align="center"   valign="baseline">
					<input type="button"  onClick="save();" value="保存">
					<input type="button"  onClick="addParameteTr();" value="新增工资系数项">
					<input type="button"  onClick="deleteChecked();" value="删除">
	  			</td>
  			</tr>	
		</table>
	</td></tr>
	 -->
	
	<tr id="btnTr"><td height="20" colspan="9">
		<table width="100%" border="0" height="20" >
			<tr >
				<td width="50%" height="20" class="datatr1"  Style="text-align:left" valign="baseline">
			
					说明：<br>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;系数区间是包含前面的，不包含后面的，例如区间为：10~30，则取值为大于等于10，小于30
					
						
	  			</td>
  			</tr>	
		</table>
	</td></tr>
</table>
</form>
<div  style="display:none">
<table id="tbCody">
	<tr ><td height="20" colspan="9"> 		
		<table  cellpadding='0' cellspacing='0' border='1' bordercolorDark='white' bordercolorLight='#BEBEBE' class="datatable">
			<tr>
				<td  height="20" align="center" style="width:40px;" rowspan="2" >
					<input id="tdIndex" name="tdIndex" value="" type="hidden">
					<input name="chktd" id="chktd"  type="checkbox"  style="width:20px;" />
	  			</td>
				<td  height="20" align="center" style="width:100px;" rowspan="2" >
					<input name="salary_percent" id="salary_percent" type="text1" class="input" style="width:40px;" />%
	  			</td>
	  			<td  height="20" align="center" class="dataTitle"  style="width:100px;" valign="baseline">工资系数项</td>
	  			<td  height="20" align="center" class="dataTitle"  style="width:100px;" valign="baseline">工资系数项单位</td>
	  			<td  height="20" align="center" class="dataTitle"  valign="baseline">
					<input name="paramete_start" id="paramete_start" type="text" class="input"  style="width:40px;" value="0"/>~<input name="paramete_end" id="paramete_end"  size="2" type="text" class="input" style="width:40px;" value="0"/>
				</td>
				<td  height="20" align="center" class="dataTitle" style="width:10px;"  valign="baseline">
				<img src="sys/images/add.gif" " onclick = "addParameteTd(this);" title="新增一项" style="cursor:hand"/>
				</td>
  			</tr>	
  			<tr >
				<td  height="20" align="center"  rowspan="2" ><input name="salary_type" id="salary_type" type="text" class="input" style="width:100%;" /></td>
	  			<td  height="20" align="center"  valign="baseline"><input name="paramete_type" id="paramete_type" type="text" class="input" style="width:40px;" /></td>
				<td  height="20" align="center" valign="baseline"><input name="paramete_percent" id="paramete_percent" type="text" class="input" style="width:40px;"  value="0" /></td>
  			</tr>
		</table>
	</td></tr>
	</table>
</div>
<div  style="display:none">
	<table id="tdCody1"><tr>
	<td  height="20" align="center" class="dataTitle"  valign="baseline">
		<input name="paramete_start" id="paramete_start" type="text" class="input"  style="width:40px;" value="0"/>~<input name="paramete_end" id="paramete_end"  size="2" type="text" class="input" style="width:40px;" value="0"/>
	</td>
	
</div>
<div style="display:none">
	<table id="tdCody2"><tr>
	<td  height="20" align="center" valign="baseline"><input name="paramete_percent" type="text" class="input" style="width:40px;"  value="0" /></td>
	
</div>
</body>
</html>
